package com.jiaquyun.jcps.app

import android.app.Application
import androidx.multidex.MultiDex
import com.blankj.utilcode.util.GsonUtils
import com.blankj.utilcode.util.SPStaticUtils
import com.google.gson.JsonSyntaxException
import com.jiaquyun.jcps.entity.UserInfoEntity

class BaseApplication : Application() {

    companion object {

        lateinit var INSTANCE: Application

        fun userInfo(): UserInfoEntity? = try {
            GsonUtils.fromJson<UserInfoEntity>(
                SPStaticUtils.getString(AppConstance.BUNDLE_USER_INFO),
                UserInfoEntity::class.java
            )
        } catch (e: JsonSyntaxException) {
            null
        }

        fun userToken(): String = SPStaticUtils.getString(AppConstance.BUNDLE_USER_TOKEN)
    }

    override fun onCreate() {
        super.onCreate()

        //获取Application
        INSTANCE = this

        MultiDex.install(this)
    }
}